package com.ckn.controller;

import com.ckn.service.PayService;
import com.xx.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author chenkangning
 * @Date 2024/6/14 9:48
 */
@RestController
@Tag(name = "支付模块",description = "选择不同的支付方式")
public class PayController {

    @Resource
    private PayService service;

    @GetMapping("/doPayV1")
    @Operation(summary = "1.if else 方式实现支付")
    @Parameter(name = "code",description = "支付方式",required = true,in = ParameterIn.QUERY)
    public Result<String> doPayV1(String code){
        return Result.ok(service.doPayV1(code));
    }

    @GetMapping("/doPayV2")
    @Operation(summary = "2.策略模式实现支付")
    @Parameter(name = "code",description = "支付方式",required = true,in = ParameterIn.QUERY)
    public Result<String> doPayV2(String code){
        return Result.ok(service.doPayV2(code));
    }

    @GetMapping("/doPayV3")
    @Operation(summary = "3.策略模式+枚举实现支付")
    @Parameter(name = "code",description = "支付方式",required = true,in = ParameterIn.QUERY)
    public Result<String> doPayV3(String code){
        return Result.ok(service.doPayV3(code));
    }

    @GetMapping("/doPayV4")
    @Operation(summary = "4.策略模式+工厂模式实现支付")
    @Parameter(name = "code",description = "支付方式",required = true,in = ParameterIn.QUERY)
    public Result<String> doPayV4(String code){
        return Result.ok(service.doPayV4(code));
    }

    
}
